#include <iostream>
#include <windows.h>

#define UNICODE

using namespace std;

PTCHAR GetArgs(){
    return ("C:\\windows\\notepad.exe");
}

INT main(VOID)
{
	PTCHAR Args;
	Args = GetArgs();
	INT ExitCode;

	STARTUPINFO si;
	ZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;

	PROCESS_INFORMATION pi;
	ZeroMemory(&pi, sizeof(pi));

	// if CreateProcess fails, exit with GetLastError, otherwise exit with (process ID * -1)
	ExitCode = CreateProcess(NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi) \
        ? pi.dwProcessId : GetLastError() * -1;


    ::WaitForSingleObject(pi.hProcess, INFINITE);
    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
	exit(0);
}
